<?php

if (isset($_POST['submit'])) {
	session_start();
	
	$mysqli=new mysqli('localhost','root','','ntz') or die ("Connetion error!");


	$username=$_POST['username'];
	$password=$_POST['password'];
       

	$query="select * from users where user='$username' AND pass='$password'";
	$res=$mysqli->query($query);
	$row=$res->num_rows;
	
	
	

	if($row==1)
	{
		$res=$res->fetch_array();
		$name=$res['user'];
		
		$_SESSION['user']=$name;
		header('location:adminpanel.php');
		echo "ok";
		exit();
	}
	else 
	{
	header('location:index.php?status=wrong-authentication');
	exit();
	}

}

else
header('location:index.php?status=no-authentication');

?>